#include <iostream>
using namespace std;
/*
n
m
v
k
n <= (m -v) * k
*/
int main() {
	int testCount(0);
	cin >> testCount;
	if (testCount <= 0) {
		return 0;
	}
	unsigned long long n(0), m(0), v(0), k(0);
	int leastCount(0);
	while (testCount--) {
		leastCount = 0;
		cin >> n >> m >> v >> k;
		if (n <= m) {
			cout << leastCount << endl;
			continue;
		}
		else {
			while ( m >= v) {
				++leastCount;
				if ((m-v) * k <= m) {
					break;
				}
				m = (m -v) * k;
				if (m >= n) {
					break;
				}
			}
			if (m >= n) {
				cout << leastCount << endl;
			}
			else {
				cout << -1 << endl;
			}
		}
	}
	return 0;
}